<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>智慧社区后台-党员活动</title>
<meta content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" name="viewport">
<link rel="stylesheet" href="${pageContext.request.contextPath}/plugins/bootstrap/css/bootstrap.min.css">
<link rel="stylesheet" href="${pageContext.request.contextPath}/css/AdminLTE.min.css">
<link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/plugins/bootstrap-table/css/bootstrap-table.css">
<link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/plugins/bootstrap-switch/css/bootstrap-switch.min.css">
</head>
<style>
</style>
<body style="padding-bottom: 90px; background-color: #ECF0F5;">
	<section class="content" style="margin: 15px; background-color: white;">
		<div class="row">
			<div class="col-sm-12">
				<table id="table">
					<thead style="background-color: #00C0EF">
						<tr style="background-color: #00C0EF">
							<th class="text-center" data-field=""></th>
							<th class="text-center" data-field="activityTitle">活动主题</th>
							<th class="text-center" data-field="activityUnit">发起单位</th>
							<th class="text-center" data-field="activityPhone">联系方式</th>
							<th class="text-center" data-field="activityProple">操作员</th>
							<th class="text-center" data-field="activityEndTime">结束时间</th>
							<th class="text-center" data-field="activityId">操作</th>
						</tr>
					</thead>
				</table>
			</div>
		</div>
	</section>
	<!-- Large modal -->
	<div id="modal" class="modal fade bs-example-modal-lg" tabindex="-1" role="dialog" aria-labelledby="myLargeModalLabel">
		<div class="modal-dialog modal-lg" role="document">
			<div class="modal-content">
				<div class="modal-header">
					<button type="button" class="close" data-dismiss="modal" aria-label="Close">
						<span aria-hidden="true">&times;</span>
					</button>
					<h4 class="modal-title">党员活动</h4>
				</div>
				<div class="modal-body">
					<div class="form-group">
						<label for="activity_title" class="control-label">活动主题:</label> <input type="text" class="form-control" id="activity_title">
					</div>
					<div class="form-group">

						<label for="activity_title" class="control-label">标题图片:</label>
						<button id="imgBtn" class="btn btn-primary glyphicon glyphicon-plus" onclick="imgFile.click();">上传图片</button>
						<img id="image" class="cover-radius" src="${pageContext.request.contextPath}/img/upload.jpg" width="150px;" style="cursor: pointer;" onclick="imgFile.click();" /> <input type="file" class="form-control" style="display: none;" name="imgFile" id="imgFile" onchange="fileChange()"> <small class="help-block cover-tips" style="color: #dd4b39; display: none;">请上传照片</small>
					</div>
					<div class="form-group">
						<label for="activity_phone" class="control-label">联系方式:</label> <input type="text" class="form-control" id="activity_phone">
					</div>
					<div class="form-group">
						<label for="activity_unit" class="control-label">发起单位:</label> <input type="text" class="form-control" id="activity_unit">
					</div>
					<div class="form-group">
						<label for="activity_prople" class="control-label">操作员:</label> <input type="text" class="form-control" value="" id="activity_prople" disabled="disabled">
					</div>
					<div class="form-group">
						<label for="activity_end_time" class="control-label">活动结束时间:</label> <input type="text" class="form-control" id="activity_end_time">
					</div>
					<div class="form-group">
						<label for="activity_content" class="control-label">活动内容描述：</label>
						<textarea rows="3" cols="20" class="form-control" id="activity_content">
						
						</textarea>
					</div>
					<div class="form-group">
						<label for="activity_content" class="control-label">是否启用说明： <input id="escapeState" name="escapeState" type="checkbox" data-size="small">
						</label>
						<textarea style="width: 100%; height: 500px;" class="form-control" rows="30" id="activity_explain" name="kindEditor_content"></textarea>
					</div>
				</div>
				<div class="modal-footer">
					<button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
					<button id="closeBtn" type="button" class="btn btn-primary" onclick="submitActivity();">提交</button>
				</div>
			</div>
		</div>
	</div>
	<div id="enrollModal" class="modal fade" tabindex="-1" role="dialog" aria-labelledby="myLargeModalLabel">
		<div class="modal-dialog" role="document">
			<div class="modal-content">
				<div class="modal-header">
					<button type="button" class="close" data-dismiss="modal" aria-label="Close">
						<span aria-hidden="true">&times;</span>
					</button>
					<h4 class="modal-title">活动报名</h4>
				</div>
				<div class="modal-body">
					<div class="row">
						<div class="col-sm-12">
							<table class="table table-condensed">
								<thead style="background-color: #00C0EF">
									<tr style="background-color: #00C0EF">
										<th class="text-center" data-field="applyName">姓名</th>
										<th class="text-center" data-field="applyTel">联系方式</th>
										<th class="text-center" data-field="applyTime">报名时间</th>
									</tr>
								</thead>
								<tbody id="enrollTable">
									<tr>
										<td class="text-center">周俊</td>
										<td class="text-center">13667352</td>
										<td class="text-center">2018-01-01</td>
									</tr>
								</tbody>
							</table>
						</div>
					</div>
				</div>
				<div class="modal-footer">
					<button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
				</div>
			</div>
		</div>
	</div>
</body>
<script src="${pageContext.request.contextPath}/plugins/jQuery/jquery-2.2.3.min.js"></script>
<script src="${pageContext.request.contextPath}/plugins/bootstrap/js/bootstrap.min.js"></script>
<script src="${pageContext.request.contextPath}/plugins/bootstrap-table/js/bootstrap-table.js"></script>
<script src="${pageContext.request.contextPath}/plugins/bootstrap-table/js/bootstrap-table-zh-CN.js"></script>
<script src="${pageContext.request.contextPath}/plugins/bootstrap-table/js/bootstrap-table-export.js"></script>
<script src="${pageContext.request.contextPath}/plugins/bootstrap-table/js/tableExport.js"></script>
<script src="${pageContext.request.contextPath}/plugins/bootstrap-table/js/bootstrap-table-toolbar.js"></script>
<script src="${pageContext.request.contextPath}/plugins/bootstrap-table/js/bootstrap-table-filter-control.js"></script>
<script src="${pageContext.request.contextPath}/plugins/bootstrap-switch/js/bootstrap-switch.min.js"></script>
<script src="${pageContext.request.contextPath}/js/ajaxfileupload.js"></script>
<!-- layer -->
<script src="${pageContext.request.contextPath}/plugins/layer/2.4/layer.js"></script>
<script src="${pageContext.request.contextPath}/plugins/laydate/laydate.js"></script>
<!-- kindeditor 编辑器 -->
<script charset="utf-8" src="${pageContext.request.contextPath}/kindeditor-4.1.10/kindeditor.js"></script>
<script charset="utf-8" src="${pageContext.request.contextPath}/kindeditor-4.1.10/lang/zh_CN.js"></script>
<script src="${pageContext.request.contextPath}/js/date.js"></script>
<script>
	var editor;
	var flag = false;
	var imgUrl = "";
	laydate.render({
		elem : '#activity_end_time',//指定元素
		// 	  type: 'datetime',
		min : (new Date()).Format("yyyy-MM-dd")
	});
	var activityId = "";
	KindEditor.ready(function(K) {
		editor = K.create('textarea[name="kindEditor_content"]', {
			items : [ 'source', '|', 'undo', 'redo', '|', 'preview', 'print', 'template', 'code', 'cut', 'copy', 'paste', 'plainpaste', 'wordpaste', '|', 'justifyleft', 'justifycenter',
					'justifyright', 'justifyfull', 'insertorderedlist', 'insertunorderedlist', 'indent', 'outdent', 'subscript', 'superscript', 'clearhtml', 'quickformat', 'selectall', '|',
					'fullscreen', '/', 'formatblock', 'fontname', 'fontsize', '|', 'forecolor', 'hilitecolor', 'bold', 'italic', 'underline', 'strikethrough', 'lineheight', 'removeformat', '|',
					'image', 'multiimage', 'flash', 'media', 'insertfile', 'table', 'hr', 'emoticons', 'baidumap', 'pagebreak', 'anchor', 'link', 'unlink', '|', 'about' ], //配置kindeditor编辑器的工具栏菜单项
			cssPath : 'kindeditor-4.1.10/plugins/code/prettify.css',
			allowFileManager : true,
			uploadJson : '${pageContext.request.contextPath}/upload_img.do', //上传
			fileManagerJson : '${pageContext.request.contextPath}/mien_file_manager.do', // 文件管理
			filterMode : true, //是否启用过滤模式(编辑文本框中是否可以出现控件显示)
			htmlTags : {
				span : [ '.color', '.background-color', '.font-size', '.font-family', '.background', '.font-weight', '.font-style', '.text-decoration', '.vertical-align', '.line-height' ],
				font : [ 'id', 'class', 'color', 'size', 'face', '.background-color' ],
				a : [ 'id', 'class', 'href', 'target', 'name' ],
				embed : [ 'id', 'class', 'src', 'width', 'height', 'type', 'loop', 'autostart', 'quality', '.width', '.height', 'align', 'allowscriptaccess' ],
				img : [ 'id', 'class', 'src', 'width', 'height', 'border', 'alt', 'title', 'align', '.width', '.height', '.border' ],
				'p,ol,ul,li,blockquote,h1,h2,h3,h4,h5,h6' : [ 'id', 'class', 'align', '.text-align', '.color', '.background-color', '.font-size', '.font-family', '.background', '.font-weight',
						'.font-style', '.text-decoration', '.vertical-align', '.text-indent', '.margin-left' ],
				pre : [ 'id', 'class' ],
				hr : [ 'id', 'class', '.page-break-after' ],
				'br,tbody,tr,strong,b,sub,sup,em,i,u,strike,s,del' : [ 'id', 'class' ],
				iframe : [ 'id', 'class', 'src', 'frameborder', 'width', 'height', '.width', '.height' ]
			},
			allowFileManager : true,
			allowUpload : false, //允许上传图片
			imageUploadJson : '/saveImg', //服务端上传图片处理URI
			resizeType : 0,//使其不可以拖动 
			afterCreate : function() {
				var self = this;
				K.ctrl(document, 13, function() {
					self.sync();
				});
				K.ctrl(self.edit.doc, 13, function() {
					self.sync();
				});
			},
			afterBlur : function() {
				this.sync();
			}
		});
// 		editor.readonly(true);
	});
	function actionFormatter(value, row, index) {
		if (row.activityState == 0) {
			return [ "<button class='btn btn-success btn-xs glyphicon glyphicon-user' onclick='showEnroll(\"" + row.activityId + "\");'>查看报名</button>",
					"&nbsp;<button class='btn btn-primary btn-xs glyphicon glyphicon-pencil' onclick='showModal(\"" + row.activityId + "\");'>编辑信息</button>",
					"&nbsp;<button class='btn btn-warning btn-xs glyphicon glyphicon-trash' onclick='cancelRecruit(\"" + row.activityId + "\")'>取消活动</button>", ].join('');
		} else if (row.activityState == 1) {
			return [ "<button class='btn btn-success btn-xs glyphicon glyphicon-user' onclick='showEnroll(\"" + row.activityId + "\");'>查看报名</button>",
					"&nbsp;<button class='btn btn-primary btn-xs glyphicon glyphicon-pencil' onclick='showInfo(\"" + row.activityId + "\");'>查看信息</button>",
					"&nbsp;<button class='btn btn-info btn-xs glyphicon glyphicon-trash'>&nbsp;已结束</button>", ].join('');
		} else if (row.activityState == 2) {
			return [ "<button class='btn btn-success btn-xs glyphicon glyphicon-user' onclick='showEnroll(\"" + row.activityId + "\");'>查看报名</button>",
					"&nbsp;<button class='btn btn-primary btn-xs glyphicon glyphicon-pencil' onclick='showInfo(\"" + row.activityId + "\");'>查看信息</button>",
					"&nbsp;<button class='btn btn-danger btn-xs glyphicon glyphicon-trash'>&nbsp;已取消</button>", ].join('');
		}
	}
	var table_dataset = [ {
		field : 'id',
		checkbox : true,
	}, {
		field : 'activityTitle',
		align : 'center',
	}, {
		field : 'activityUnit',
		align : 'center',
	}, {
		field : 'activityPhone',
		align : 'center',
	}, {
		field : 'activityProple',
		align : 'center',
	}, {
		field : 'activityEndTime',
		align : 'center',
		formatter : function timeFormatter(value, row, index) {
			return (new Date(row.activityEndTime)).Format("yyyy-MM-dd hh:mm:ss");
		}
	}, {
		align : 'center',
		width : 300,
		formatter : actionFormatter,
	} ];
	$('#table').bootstrapTable(
			{
				url : "${pageContext.request.contextPath}/activity/selectActivityPage",
				idField : "activityId",
				columns : table_dataset,
				striped : true, //是否显示行间隔色
				pagination : true, //是否显示分页
				pageSize : 10, //每页的记录行数
				pageList : [ 10, 25, 50, 100 ], //可供选择的每页的行数
				search : false, //是否显示搜索
				showRefresh : true,
				sidePagination : "server", //表示服务端请求  
				queryParamsType : "limit",
				queryParams : function queryParams(params) { //设置查询参数  
					var param = {
						offset : params.offset,
						limit : params.limit,
						kod : $("#kod").val(),
						kodType : $("#kodType").val()
					};
					return param;
				},
				toolbar : "<button style='float:left;' class='btn btn-primary glyphicon glyphicon-plus' onclick='showModal(\"" + '' + "\");'>新增活动</button>"
						+ "<div  style='width:250px;float:left;margin-top:2px;margin-left:20px;'>" + "<select id='kodType' name='stateType' class='form-control' onchange='Querry()'>"
						+ "<option value=''>全部</option>" + "<option value=0>正在报名</option>" + "<option value=1>已结束</option>" + "<option value=2>取消活动</option>" + "</select></div>"
						+ "<div class='input-group' style='width:250px;float:right;margin-top:2px;margin-left:20px;'><input type='text' class='form-control' placeholder='请输入活动主题' id='kod' name='kod'>"
						+ "<span class='input-group-btn'><button class='btn btn-default' type='button' onclick='Querry(\"" + '' + "\");'>查询</button></span></div>",
				icons : {
					paginationSwitchDown : 'glyphicon-collapse-down icon-chevron-down',
					paginationSwitchUp : 'glyphicon-collapse-up icon-chevron-up',
					refresh : 'glyphicon-refresh icon-refresh',
					toggle : 'glyphicon-list-alt icon-list-alt',
					columns : 'glyphicon-th icon-th',
					detailOpen : 'glyphicon-plus icon-plus',
					detailClose : 'glyphicon-minus icon-minus',
					"export" : 'glyphicon-export icon-share'
				},
				showExport : true,
				exportDataType : 'basic',
				exportTypes : [ 'json', 'xml', 'csv', 'txt', 'sql', 'excel' ]
			});

	$(function() {
		// 		$("#activity_explain").hide();
		$("#escapeState").bootstrapSwitch({
			onText : "启用",
			offText : "禁用",
			onColor : "info",
			offColor : "warning",
			size : "small",
			state : false,
			onSwitchChange : function(event, state) {
				flag = state;
				if (state) {
					// 	            	$("#activity_explain").show();
					editor.readonly(false);
				} else {
					// 	            	$("#activity_explain").hide(); 
					editor.readonly(true);
					editor.html('');
				}
			}
		});
		$("#image").hide();
	});

	function showModal(id) {
		enableChiose(false);
		editor.html('');
		if (id == "") {
			activityId = '';
			$("#activity_title").val('');
			imgUrl = "";
			$("#imgBtn").show();
			$('#image').attr('src', '');
			$("#activity_phone").val('');
			$("#activity_unit").val('');
			$("#activity_end_time").val('');
			$("#activity_content").val('');
			$("#activity_prople").val("${sessionScope.userAccount}");
			flag = false;
			$("#escapeState").bootstrapSwitch('state', false, true);
			// 			$("#activity_explain").hide();
			editor.readonly(true);
			// 			$("#activity_explain").val('');
			$('#modal').modal({
				backdrop : 'static',
				keyboard : false
			});
		} else {
			activityId = id;
			$.ajax({
				url : "${pageContext.request.contextPath}/activity/selectActivityById",
				type : "get",
				data : {
					activityId : activityId
				},
				dataType : "json",
				success : function(data) {
					var memberActivity = data.result;
					$("#activity_title").val(memberActivity.activityTitle);
					$('#image').attr('src', '');
					if (memberActivity.activityImg != null && memberActivity.activityImg != "") {
						imgUrl = memberActivity.activityImg;
						$('#image').attr('src', '${pageContext.request.contextPath}/' + memberActivity.activityImg);
						$("#imgBtn").hide();
						$('#image').show();
					} else {
						$("#imgBtn").show();
					}
					$("#activity_phone").val(memberActivity.activityPhone);
					$("#activity_unit").val(memberActivity.activityUnit);
					$("#activity_end_time").val((new Date(memberActivity.activityEndTime)).Format("yyyy-MM-dd"));
					$("#activity_content").val(memberActivity.activityContent);
					$("#activity_prople").val(memberActivity.activityProple);
					if (memberActivity.activityExplainState == 0) {
						flag = false;
						$("#escapeState").bootstrapSwitch('state', false, true);
						editor.readonly(true);
					} else if (memberActivity.activityExplainState == 1) {
						flag = true;
						$("#escapeState").bootstrapSwitch('state', true, true);
						editor.readonly(false);
						editor.html(memberActivity.activityExplain)
					}
					$('#modal').modal({
						backdrop : 'static',
						keyboard : false
					});
				},
				error : function() {
					layer.msg('系统异常!', {
						icon : 2,
						time : 800
					});
				}
			});
		}
	}
	//查看信息
	function showInfo(id) {
		activityId = id;
		$.ajax({
			url : "${pageContext.request.contextPath}/activity/selectActivityById",
			type : "get",
			data : {
				activityId : activityId
			},
			dataType : "json",
			success : function(data) {
				var memberActivity = data.result;
				$("#activity_title").val(memberActivity.activityTitle);
				$('#image').attr('src', '');
				if (memberActivity.activityImg != null && memberActivity.activityImg != "") {
					imgUrl = memberActivity.activityImg;
					$('#image').attr('src', '${pageContext.request.contextPath}/' + memberActivity.activityImg);
					$("#imgBtn").hide();
					$('#image').show();
				} else {
					$("#imgBtn").show();
				}
				$("#activity_phone").val(memberActivity.activityPhone);
				$("#activity_unit").val(memberActivity.activityUnit);
				$("#activity_end_time").val((new Date(memberActivity.activityEndTime)).Format("yyyy-MM-dd"));
				$("#activity_content").val(memberActivity.activityContent);
				$("#activity_prople").val(memberActivity.activityProple);
				if (memberActivity.activityExplainState == 0) {
					flag = false;
					$("#escapeState").bootstrapSwitch('state', false, true);
					// 					$("#activity_explain").hide();
					editor.readonly(true);
				} else if (memberActivity.activityExplainState == 1) {
					flag = true;
					$("#escapeState").bootstrapSwitch('state', true, true);
					// 					$("#activity_explain").show();
					editor.readonly(false);
					// 					$("#activity_explain").val(recruit.activity_explain);
					editor.html(memberActivity.activityExplain)
				}
				enableChiose(true);
				$('#modal').modal({
					backdrop : 'static',
					keyboard : false
				});
			},
			error : function() {
				layer.msg('系统异常!', {
					icon : 2,
					time : 800
				});
			}
		});
	}

	function enableChiose(type) {
		$("#activity_title").attr("disabled", type);
		$("#image").attr("disabled", type);
		$("#activity_phone").attr("disabled", type);
		$("#activity_unit").attr("disabled", type);
		$("#activity_end_time").attr("disabled", type);
		$("#activity_content").attr("disabled", type);
		$("#escapeState").bootstrapSwitch('disabled', type);
		// 		$("#activity_explain").attr("disabled", type);
		// 		$("#activity_explain").val('');
		editor.readonly(type);
		$('#image').attr('disabled', type);
		$('#imgBtn').attr('disabled', type);
		if (type) {
			$("#closeBtn").hide();
		} else {
			$("#closeBtn").show();
		}
	}
	//显示报名信息
	function showEnroll(id) {
		activityId = id;
		$.ajax({
			url : "${pageContext.request.contextPath}/activity/selectActivityApply",
			type : "get",
			data : {
				activityId : activityId
			},
			dataType : "json",
			success : function(data) {
				var list = data.result;
				var html = "";
				if (list.length == 0) {
					html = "<tr><td colspan='3' class='text-center'>暂无人报名</td></tr>"
				}
				for (var i = 0; i < list.length; i++) {
					html += "<tr><td class='text-center'>" + list[i].applyName + "</td><td class='text-center'>" + list[i].applyTel + "</td><td class='text-center'>" + list[i].applyTime
							+ "</td></tr>";
				}
				$("#enrollTable").html(html);
				$('#enrollModal').modal({
					backdrop : 'static',
					keyboard : false
				});
			},
			error : function() {
				layer.msg('系统异常!', {
					icon : 2,
					time : 800
				});
			}
		});
	}

	//保存
	function submitActivity() {
		$("#closeBtn").button('loading');
		var activityTitle = $('#activity_title').val();
		var activityImg = imgUrl;
		var activityPhone = $('#activity_phone').val();
		var activityUnit = $("#activity_unit").val();
		var activityEndTime = $('#activity_end_time').val();
		var activityContent = $('#activity_content').val();
		var activityProple = $('#activity_prople').val();
		if (activityTitle === '' || activityEndTime === '' || activityContent === '' || activityUnit === '' || activityPhone === '') {
			layer.alert("新增的数据中填写不完整!");
			$("#closeBtn").button('reset');
			return false;
		}
		// 		if (editor.isEmpty()) {
		// 			layer.alert("新增的数据中填写不完整!");
		// 			$("#closeBtn").button('reset');
		// 			return false;
		// 		}
		if (!(/^1([38]\d|5[0-35-9]|7[3678])\d{8}$/.test(activityPhone))) {
			layer.alert("联系方式格式不正确！");
			$("#closeBtn").button('reset');
			return false;
		}
		var escapeState = 0;
		var activity_explain = null;
		if (flag) {
			escapeState = 1;
			activity_explain = $("#activity_explain").val();
			if (editor.isEmpty()) {
				layer.alert("新增的数据中填写不完整!");
				$("#closeBtn").button('reset');
				return false;
			}
		}

		var url = activityId === '' ? '${pageContext.request.contextPath}/activity/insertActivity' : '${pageContext.request.contextPath}/activity/updateActivity';

		$.ajax({
			url : url,
			type : "post",
			data : {
				activityId : activityId,
				activityTitle : activityTitle,
				activityImg : activityImg,
				activityPhone : activityPhone,
				activityUnit : activityUnit,
				activityEndTimeStr : activityEndTime,
				activityContent : activityContent,
				activityExplainState : escapeState,
				activityExplain : activity_explain,
				activityProple : activityProple
			},
			dataType : "json",
			success : function(data) {
				var result = data['result'];
				if (result === 1) {
					layer.msg('操作成功!', {
						icon : 1,
						time : 800
					});
					setTimeout(function() {
						$("#table").bootstrapTable('refresh');
						$("#modal").modal("hide");
					}, 1000);
				} else {
					layer.msg('操作失败!', {
						icon : 2,
						time : 800
					});
				}
				$("#closeBtn").button('reset');
			},
			error : function() {
				layer.msg('系统繁忙，请稍后再试!', {
					icon : 2,
					time : 800
				});
				$("#closeBtn").button('reset');
			}
		});

		return false;
	}

	//取消招募
	function cancelRecruit(id) {
		layer.confirm("是否要取消活动？", function(index) {
			$.ajax({
				url : "${pageContext.request.contextPath}/activity/updateActivity",
				type : "post",
				data : {
					activityId : id,
					activityState : 2
				},
				dataType : "json",
				success : function(data) {
					if (data.result == 1) {
						$("#table").bootstrapTable('refresh');
						layer.msg('操作成功!', {
							icon : 1,
							time : 800
						});
					} else {
						layer.msg('操作失败!', {
							icon : 2,
							time : 800
						});
					}
				},
				error : function() {
					layer.msg('系统繁忙，请稍后再试!', {
						icon : 5,
						time : 800
					});
				}
			});
		});
	}

	function fileChange() {
		//document.getElementById("upload_file_img").value = document.getElementById("imgFile").value;
		if (image_check('imgFile')) { //自己添加的文件后缀名的验证
			$.ajaxFileUpload({
				fileElementId : 'imgFile', //需要上传的文件域的ID，即<input type="file">的ID。
				url : "${pageContext.request.contextPath}/upload_img", //后台方法的路径
				type : 'post', //当要提交自定义参数时，这个参数要设置成post
				dataType : 'json', //服务器返回的数据类型。可以为xml,script,json,html。如果不填写，jQuery会自动判断。
				secureuri : false, //是否启用安全提交，默认为false。
				async : true, //是否是异步
				success : function(data) { //提交成功后自动执行的处理函数，参数data就是服务器返回的数据。
					imgUrl = data.url;
					$('#image').attr('src', '${pageContext.request.contextPath}/' + data.url);
					$("#image").show();
					$("#imgBtn").hide();
				}
			//                 error: function(data, status, e) {  //提交失败自动执行的处理函数。
			//                     console.error(e);
			//                 }
			});
		}
	}

	function Querry() {
		$("#table").bootstrapTable('refresh');
	}

	function image_check(feid) { //自己添加的文件后缀名的验证
		var img = document.getElementById(feid);
		return /.(jpg|png|gif|bmp)$/.test(img.value) ? true : (function() {
			layer.alert('图片格式仅支持jpg、png、gif、bmp格式，且区分大小写。');
			return false;
		})();
	}
</script>
</html>
